import request from '@/utils/request'

// 查询打印文件上传列表
export function listPrintFileUpload(query) {
  return request({
    url: '/print/file/list',
    method: 'get',
    params: query
  })
}

// 查询打印文件上传详细
export function getPrintFileUpload(id) {
  return request({
    url: '/print/file/' + id,
    method: 'get'
  })
}

// 新增打印文件上传
export function addPrintFileUpload(data) {
  return request({
    url: '/print/file',
    method: 'post',
    data: data
  })
}

// 修改打印文件上传
export function updatePrintFileUpload(data) {
  return request({
    url: '/print/file',
    method: 'put',
    data: data
  })
}

// 删除打印文件上传
export function delPrintFileUpload(id) {
  return request({
    url: '/print/file/' + id,
    method: 'delete'
  })
}

// 上传打印文件
export function uploadPrintFile(file) {
  const formData = new FormData()
  formData.append('file', file)
  return request({
    url: '/print/file/upload',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 批量上传打印文件
export function batchUploadPrintFiles(files) {
  const formData = new FormData()
  files.forEach(file => {
    formData.append('files', file)
  })
  return request({
    url: '/print/file/batch-upload',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 获取支持的文件类型
export function getSupportedTypes() {
  return request({
    url: '/print/file/supported-types',
    method: 'get'
  })
}

// 删除OSS文件
export function deleteOssFile(url) {
  return request({
    url: '/print/file/delete-oss',
    method: 'delete',
    params: { url }
  })
} 